
appUrl="http://localhost:8400/";




$.MENU= "<ul class=\"side-navigation\">\n" +
    "                <li>\n" +
    "                    <h3 class=\"navigation-title\"></h3>\n" +
    "                </li>\n" +
    "                <li class=\"menu-list\"><a href=\"#\"><i class=\"fa fa-university\"></i> <span>店铺管理</span></a>\n" +
    "                    <ul class=\"child-list\">\n" +
    "                        <li ><a href=\"/shop.html\"> 店铺列表</a></li>\n" +
    "                        <li ><a href=\"#\"> </a></li>\n" +
    "                    </ul>\n" +
    "                </li>\n" +
    "                <li class=\"menu-list\"><a href=\"#\"><i class=\"mdi mdi-google-circles-extended\"></i> <span>商品管理 <span\n" +
    "                        class=\"badge badge-primary noti-arrow pull-right\">6</span> </span></a>\n" +
    "                    <ul class=\"child-list\">\n" +
    "                        <li><a href=\"/goodslist.html\"> 商品管理</a></li>\n" +
    "                        <li><a href=\"#\"></a></li>\n" +
    "                    </ul>\n" +
    "                </li>\n" +

    "                <li class=\"menu-list\"><a href=\"#\"><i class=\"mdi mdi-diamond\"></i> <span>销售订单管理</span></a>\n" +
    "                    <ul class=\"child-list \" >\n" +
    "                        <li><a href=\"/order.html\"> 销售订单列表</a></li>\n" +
    "                    </ul>\n" +
    "                </li>\n" +
    "                <li class=\"menu-list\"><a href=\"#\"><i class=\"mdi mdi-chart-arc\"></i> <span>用户管理 </span></a>\n" +
    "                    <ul class=\"child-list\">\n" +
    "                        <li><a href=\"pages-changepwd.html\">修改密码</a></li>\n" +
    "                        <li><a href=\"pages-login.html\">注销</a></li>\n" +
    "                    </ul>\n" +
    "                </li>\n" +
    "            </ul>";





$.ajaxPrefilter( function(options, originalOptions, jqXHR){
    // options对象 包括accepts、crossDomain、contentType、url、async、type、headers、error、dataType等许多参数选项
    // originalOptions对象 就是你为$.ajax()方法传递的参数对象，也就是 { url: "/index.php" }
    // jqXHR对象 就是经过jQuery封装的XMLHttpRequest对象(保留了其本身的属性和方法)

    var o=$('.tyds-filter');

    if(!!originalOptions.data){


        var conn="";
        $('.tyds-filter').find("input").each(function (i,k) {


            if(k.getAttribute("types")=='equals'){

                var name = k.getAttribute("name");
                var value =$(k).val();
                if(value!="" && value !=undefined){
                    conn+=name+"="+"'"+value+"' and ";
                }
            }
            if(k.getAttribute("types")=='like'){
                var name = k.getAttribute("name");
                var value =$(k).val();
                if(value!="" && value !=undefined){
                    conn+=name+" like "+" '%"+value+"%'  and ";
                }
            }

        });


        $('.tyds-filter').find("select").each(function (i,k) {

            if(k.getAttribute("types")=='equals'){

                var name = k.getAttribute("name");
                var value =$(k).val();
                if(value!="-1" && value !=undefined && value!=""){
                    conn+=name+"="+"'"+value+"' and ";
                }
            }
            if(k.getAttribute("types")=='like'){
                var name = k.getAttribute("name");
                var value =$(k).val();
                if(value!="-1" && value !=undefined && value!=""){
                    conn+=name+" like "+" '%"+value+"%'  and ";
                }
            }

        });

        conn+=" 1=1 ";

        originalOptions.data.conn = conn;
    }


    if(Object.prototype.toString.call(options.data) == "[object FormData]"){
        options.data.append("userid","11111");
    }else if(Object.prototype.toString.call(options.data) == "[object String]"){
        if(Object.prototype.toString.call(originalOptions.data) == "[object Object]"){
            options.data = $.param($.extend(originalOptions.data||{}, {
                userid: "1111111"
            }));
        }else if(Object.prototype.toString.call(originalOptions.data) == "[object String]"){
            options.data = options.data+"&userid="+"1111111";
        }
    }
    console.log(options);
    console.log(options.headers);
    console.log(originalOptions);
    console.log(jqXHR);
});

// common scripts
(function() {


    if(localStorage.user==undefined){

        window.location.href='pages-login.html'
    }


    document.getElementsByClassName('sidebar-left-info')[0].innerHTML=$.MENU;

    var targetUrl = window.location.pathname;
    targetUrl = targetUrl.replace("/web/",'');

    jQuery('.child-list a').each(function() {


        var me  = this;
        var parent = jQuery(this).parent();

        var parents = jQuery(this).parent().parent().parent();


        if(me.href.indexOf(targetUrl)!=-1 && me.href.indexOf('#')==-1){

            parent.addClass('active');
            parents.addClass('nav-active');
        }

    });

    "use strict";

    // Sidebar toggle

    jQuery('.menu-list > a').click(function() {

        var parent = jQuery(this).parent();
        var sub = parent.find('> ul');

        if(!jQuery('body').hasClass('sidebar-collapsed')) {
            if(sub.is(':visible')) {
                sub.slideUp(300, function(){
                    parent.removeClass('nav-active');
                    jQuery('.body-content').css({height: ''});
                    adjustMainContentHeight();
                });
            } else {
                visibleSubMenuClose();
                parent.addClass('nav-active');
                sub.slideDown(300, function(){
                    adjustMainContentHeight();
                });
            }
        }
        return false;
    });

    function visibleSubMenuClose() {

        jQuery('.menu-list').each(function() {
            var t = jQuery(this);
            if(t.hasClass('nav-active')) {
                t.find('> ul').slideUp(300, function(){
                    t.removeClass('nav-active');
                });
            }
        });
    }

    function adjustMainContentHeight() {

        // Adjust main content height
        var docHeight = jQuery(document).height();
        if(docHeight > jQuery('.body-content').height())
            jQuery('.body-content').height(docHeight);
    }

    // add class mouse hover

    jQuery('.side-navigation > li').hover(function(){
        jQuery(this).addClass('nav-hover');
    }, function(){
        jQuery(this).removeClass('nav-hover');
    });




    // Toggle Menu

    jQuery('.toggle-btn').click(function(){

        var body = jQuery('body');
        var bodyposition = body.css('position');

        if(bodyposition != 'relative') {

            if(!body.hasClass('sidebar-collapsed')) {
                window.localStorage.menuType="close";
                body.addClass('sidebar-collapsed');
                jQuery('.side-navigation ul').attr('style','');

            } else {

                window.localStorage.menuType="open";
                body.removeClass('sidebar-collapsed chat-view');
                jQuery('.side-navigation li.active ul').css({display: 'block'});

            }
        } else {

            if(body.hasClass('sidebar-open')){
                window.localStorage.menuType="open";
                body.removeClass('sidebar-open');
            }
            else {
                window.localStorage.menuType="open";
                body.addClass('sidebar-open');
            }
            adjustMainContentHeight();
        }

        //var owl = $("#news-feed").data("owlCarousel");
        //owl.reinit();

    });





    // right slidebar

    $(function(){
        $.slidebars();
    });

    $(".notification-scroll").slimScroll({
        height: "240px"
    });

    $(".slimscroll").slimScroll({
        height: 'auto',
        position: 'right',
        size: "7px",
        color: '#98a6ad',
        wheelStep: 13
    });





    // collapsible panel

    $('.panel .tools .t-collapse').click(function () {
        var el = $(this).parents(".panel").children(".panel-body");
        if ($(this).hasClass("fa-chevron-down")) {
            $(this).removeClass("fa-chevron-down").addClass("fa-chevron-up");
            el.slideUp(200);
        } else {
            $(this).removeClass("fa-chevron-up").addClass("fa-chevron-down");
            el.slideDown(200); }
    });


    // close panel
    $('.panel .tools .t-close').click(function () {
        $(this).parents(".panel").parent().remove();
    });


    // side widget close

    $('.side-w-close').on('click', function(ev) {
        ev.preventDefault();
        $(this).parents('.aside-widget').slideUp();
    });
    $('.info .add-people').on('click', function(ev) {
        ev.preventDefault();
        $(this).parents('.tab-pane').children('.aside-widget').slideDown();

    });


    // refresh panel

    $('.box-refresh').on('click', function(br) {
        br.preventDefault();
        $("<div class='refresh-block'><span class='refresh-loader'><i class='fa fa-spinner fa-spin'></i></span></div>").appendTo($(this).parents('.tools').parents('.panel-heading').parents('.panel'));

        setTimeout(function() {
            $('.refresh-block').remove();
        }, 1000);

    });

    $('.btn-animation').on('click', function(br) {
        //adding animation
        $('.modal .modal-dialog').attr('class', 'modal-dialog  ' + $(this).data("animation") + '  animated');
    });


    $(function () {
        $('[data-toggle="popover"]').popover()
    })

    $(function () {
        $('[data-toggle="tooltip"]').tooltip()
    })



    // tool tips

    $('.tooltips').tooltip();

    // popovers

    $('.popovers').popover();


})(jQuery);

//portlets
!function($) {
    "use strict";

    /**
     Portlet Widget
     */
    var Portlet = function() {
        this.$body = $("body"),
            this.$portletIdentifier = ".portlet",
            this.$portletRefresher = '.portlet a[data-toggle="reload"]'
    };

    //on init
    Portlet.prototype.init = function() {
        // Panel closest
        var $this = this;

        // Panel Reload
        $(document).on("click",this.$portletRefresher, function (ev) {
            ev.preventDefault();
            var $portlet = $(this).closest($this.$portletIdentifier);
            // This is just a simulation, nothing is going to be reloaded
            $portlet.append('<div class="panel-disabled"><div class="loader-1"></div></div>');
            var $pd = $portlet.find('.panel-disabled');
            setTimeout(function () {
                $pd.fadeOut('fast', function () {
                    $pd.remove();
                });
            }, 500 + 300 * (Math.random() * 5));
        });
    },
        //
        $.Portlet = new Portlet, $.Portlet.Constructor = Portlet

}(window.jQuery),

    /**
     * Components
     */
    function($) {
        "use strict";

        var Components = function() {};
        //initilizing
        Components.prototype.init = function() {
            var $this = this;
            //creating portles
            $.Portlet.init();
        },

            $.Components = new Components, $.Components.Constructor = Components

    }(window.jQuery),
    //initializing main application module
    function($) {
        "use strict";
        $.Components.init();
    }(window.jQuery);

$.extend( $.fn.dataTable.defaults, {
    searching: false,
    ordering:  false,
    paging: true,
    info: false,
    lengthChange: false,
    full_numbers:'第一页,前一页,后一页,最后页,数字',
    pagingType: "full_numbers",
    language: {
        "processing": "数据正在处理中",
        // 当前页显示多少条
        "lengthMenu": "当前页显示多少条",
        // _START_（当前页的第一条的序号） ,_END_（当前页的最后一条的序号）,_TOTAL_（筛选后的总件数）,
        // _MAX_(总件数),_PAGE_(当前页号),_PAGES_（总页数）
        "info": "Showing page _PAGE_ of _PAGES_",
        // 没有数据的显示（可选），如果没指定，会用zeroRecords的内容
        "emptyTable": "没有数据的显示",
        // 筛选后，没有数据的表示信息，注意emptyTable优先级更高
        "zeroRecords": "筛选信息为空",
        // 千分位的符号，只对显示有效，默认就是","  一般不要改写
        //"thousands": "'",
        // 小数点位的符号，对输入解析有影响，默认就是"." 一般不要改写
        //"decimal": "-",
        // 翻页按钮文字控制
        "paginate": {
            "first": "第一页",
            "last": "最后一页",
            "next": "下一页",
            "previous": "前一页"
        },
        // Client-Side用，Server-Side不用这个属性
        "loadingRecords": "请稍后 - 加载中..."
    },
} );
